<% html_title l(:knowledgebase_title) %>

<div class="contextual">
  <%= render :partial => "categories/jump_box" %>
  <%= link_to_if_authorized l(:title_create_category), { :controller => 'categories', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
  <% if @project.categories.length > 0 %>	
    <%= link_to_if_authorized l(:title_create_article), { :controller => 'articles', :action => 'new', :project_id => @project}, :class => 'icon icon-add' %>
  <% end %>
</div>

<% if @project.categories.count == 0 %>
  </br>
  <p class="nodata"><%= l(:message_no_categories) %></p>
  
<% elsif @project.articles.count == 0 %>
  </br>
  <p class="nodata"><%= l(:message_no_articles) %></p>
  
<% else %>
  <% if User.current.allowed_to?(:view_kb_articles, @project) %>
    <div class="splitcontentleft">
        <h2><%=l(:label_overview)%></h2>
        <div class="articles box">
        <h3><%= l(:title_overview_summary) %></h3>
        <ul>
            <li><%= l(:label_overview_total_categories, :total_categories => @total_categories.to_i) %></li>
            <li><%= l(:label_overview_total_articles, :total_articles => @total_articles.to_i) %></li>
            <% if User.current.allowed_to?(:create_articles, @project) %>
              <li><%= l(:label_overview_my_articles, :total_articles_by_me => @total_articles_by_me.to_i) %></li>
            <% end %>
        </ul>
        </div>
        <% if User.current.allowed_to?(:view_recent_articles, @project) %>
          <h3><%= l(:title_recently_updated_articles) %></h3>
          <div class="articles index-summary">
              <%= render :partial => 'articles/list', :locals => { :summary_format => "updated", :articles => @articles_latest, :default_icon => 'recently-changed' } %>
          </div>
        <% end %>
    </div>

    <div class="splitcontentright">
        <% if User.current.allowed_to?(:view_most_popular_articles,@project) %>
          <h3><%= l(:title_most_popular_articles) %></h3>
          <div class="articles index-summary">
              <%= render :partial => 'articles/list', :locals => { :summary_format => "popular", :articles => @articles_popular, :default_icon => 'popular' } %>
          </div>
        <% end %>
        <% if User.current.allowed_to?(:view_top_rated_articles, @project) %>
          <h3><%= l(:title_top_rated_articles) %></h3>
          <div class="articles index-summary">
              <%= render :partial => 'articles/list', :locals => { :summary_format => "toprated", :articles => @articles_latest, :default_icon => 'top-rated' } %>
          </div>
        <% end %>
    </div>
    
    <% content_for :sidebar do %>
            <h3><%= l(:title_browse_by_category) %></h3>
            <%= render :partial => "categories/tree" %>
            </br>
        <div id="taglist">
            <h3>Browse by Tags</h3>
            <% tag_cloud(@tags, ['tag-x-small', 'tag-small', 'tag-medium', 'tag-large', 'tag-x-large']) do |tag, css_class| %>
            <%= link_to(tag.name, {:controller => 'articles', :action => :tagged, :id => tag.name }, :class => "tag #{css_class}") %>
            <% end %>
        </div>
    <% end %>
  <% else %>
     <p class="nodata"><%=l(:message_no_permissions)%></p>
  <% end %>
<% end %>

<% content_for :header_tags do %>
    <%= stylesheet_link_tag 'knowledgebase', :plugin => 'redmine_knowledgebase' %>
<% end %>
